package body Performances is
   
   procedure Reset (this : in out Monitor_Type)
   is
      pragma Inline (Reset);
   begin
      this.Consumed_Time := 0.0;
      this.Sample_Count := 0;
   end Reset;

   procedure Start (this : in out Monitor_Type)
   is
      pragma Inline (Start);
   begin
      this.Start_Time := Ada.Calendar.Clock;
   end Start;

   procedure Stop (this : in out Monitor_Type)
   is
      pragma Inline (Stop);
      use type Ada.Calendar.Time;
   begin
      this.Stop_Time := Ada.Calendar.Clock;
      this.Consumed_Time := this.Consumed_Time + (this.Stop_Time - this.Start_Time);
      this.Sample_Count := this.Sample_Count + 1;
   end Stop;

   function Consumed (this : in out Monitor_Type) return Duration
   is
      pragma Inline (Consumed);
   begin
      return this.Consumed_Time;
   end Consumed;


   function Average (this : in out Monitor_Type) return Duration
   is
      pragma Inline (Average);
   begin
      if this.Sample_Count > 0 then
	 return this.Consumed_Time / Duration(this.Sample_Count);
      else
	 return 0.0;
      end if;
   end Average;

   function Count (this : in out Monitor_Type) return Natural
   is
      pragma Inline (Count);
   begin
      return this.Sample_Count;
   end Count;

   overriding 
   procedure Initialize (this : in out Monitor_Type)
   is
   begin
      Reset (this);
   end Initialize;

end Performances;
